package com.zhihuichongcheng.application.ui.approval.fragment;

import android.support.v7.widget.LinearLayoutManager;

import com.jcodecraeer.xrecyclerview.XRecyclerView;
import com.smartlib.cmnObject.recycleView.OnItemOnclick;
import com.zhihuichongcheng.application.R;
import com.zhihuichongcheng.application.base.BaseFragment;
import com.zhihuichongcheng.application.bean.approval.ApprovalWaitBean;
import com.zhihuichongcheng.application.ui.approval.activity.ApprovalDetailActivity;
import com.zhihuichongcheng.application.ui.approval.adapter.SendTomeApprovalAdapter;
import com.zhihuichongcheng.application.util.RecycleViewDivider;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 3water on 2016/11/10.
 */

public class SendTomeApprovalFragment extends BaseFragment {
    private List<ApprovalWaitBean> mListData = new ArrayList<>();
    private XRecyclerView mRcvApproval;
    private SendTomeApprovalAdapter mAdapter = null;

    @Override
    protected void init() {
        super.init();
        initView();
        initData();
    }

    private void initView()
    {
        mRcvApproval = (XRecyclerView)mView.findViewById(R.id.rcv_approvalList);
        mRcvApproval.setLayoutManager(new LinearLayoutManager(mContext));
        mRcvApproval.addItemDecoration(new RecycleViewDivider(mContext,LinearLayoutManager.VERTICAL,2,getResources().getColor(R.color.color_d8d8d8)));
        mAdapter = new SendTomeApprovalAdapter(mContext);
        mAdapter.setOnItemOnclick(new OnItemOnclick<ApprovalWaitBean>() {
            @Override
            public void onClick(ApprovalWaitBean approvalBean, int position) {
                startActivity(ApprovalDetailActivity.class,null);
            }
        });
        mRcvApproval.setAdapter(mAdapter);
    }

    private void initData()
    {
        for (int i=0;i<10;i++)
        {
            ApprovalWaitBean bean = new ApprovalWaitBean();
//            bean.setTitle("客场申请单");
//            bean.setName("风的记忆");
//            bean.setTime("10-31 12:31");
            mListData.add(bean);
        }
        mAdapter.setdata(mListData);
        mAdapter.notifyDataSetChanged();

    }

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_approval_list;
    }
}
